package com.project.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.project.bean.ClassBean;
import com.project.bean.StudentBean;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface IClassMapper extends BaseMapper<ClassBean> {

    @Select("select * from t_class")
    @ResultMap("classMap")
    List<ClassBean> findAll();


    @Delete("delete from t_class where pk_classId=#{id}")
    void del(Integer id);

    @Select("SELECT COUNT(s.`pk_studentId`) sum FROM t_student s JOIN t_class c ON s.`fk_classId`=c.`pk_classId` WHERE c.`pk_classId`=#{id}")
    @ResultMap("classMap")
    ClassBean countByClass(Integer id);


    void add(ClassBean classBean);
}
